package com.jeesite.modules.isys.utils;

import com.jeesite.modules.isys.iac.entity.IACMeta;

import java.util.Date;
import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom;

public class IACMetaUtil {

    public static IACMeta generateRandomIACMeta() {
        IACMeta iacMeta = new IACMeta();

        // 唯一标识符，使用UUID
        iacMeta.setUuid(UUID.randomUUID().toString());
        // 设备编号，假定在一定范围内随机生成
        iacMeta.setDeviceId(ThreadLocalRandom.current().nextLong(1, 10000));
        // 环境监测数据，根据实际范围生成随机数
        iacMeta.setPm25(ThreadLocalRandom.current().nextDouble(0, 500));
        iacMeta.setPm10(ThreadLocalRandom.current().nextDouble(0, 500));
        iacMeta.setTsp(ThreadLocalRandom.current().nextDouble(0, 1000));
        iacMeta.setTemperature(ThreadLocalRandom.current().nextDouble(-40, 50));
        iacMeta.setHumidity(ThreadLocalRandom.current().nextDouble(0, 100));
        iacMeta.setNoise(ThreadLocalRandom.current().nextDouble(30, 130));
        iacMeta.setWindDirection(ThreadLocalRandom.current().nextInt(0, 360));
        iacMeta.setWindSpeed(ThreadLocalRandom.current().nextDouble(0, 150));
        iacMeta.setOzone(ThreadLocalRandom.current().nextDouble(0, 300));
        iacMeta.setApi(ThreadLocalRandom.current().nextInt(0, 500));
        iacMeta.setSo2(ThreadLocalRandom.current().nextDouble(0, 500));
        iacMeta.setO3(ThreadLocalRandom.current().nextDouble(0, 300));
        iacMeta.setCo(ThreadLocalRandom.current().nextDouble(0, 50));
        iacMeta.setNo2(ThreadLocalRandom.current().nextDouble(0, 200));
        iacMeta.setBarometric(ThreadLocalRandom.current().nextDouble(900, 1100));
        // 创建和更新时间
        Date now = new Date();
        iacMeta.setCreateTime(now);
        iacMeta.setUpdateTime(now);

        return iacMeta;
    }

}
